function Split(szFullString, szSeparator)  
local nFindStartIndex = 1  
local nSplitIndex = 1  
local nSplitArray = {}  
while true do  
   local nFindLastIndex = string.find(szFullString, szSeparator, nFindStartIndex)  
   if not nFindLastIndex then  
    nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, string.len(szFullString))  
    break  
   end  
   nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, nFindLastIndex - 1)  
   nFindStartIndex = nFindLastIndex + string.len(szSeparator)  
   nSplitIndex = nSplitIndex + 1  
end  
return nSplitArray  
end

function try_save(user,pass)

    local up = {}

    file = io.open("./up.data","a+")
    io.input(file)

    for value in io.lines() do
        local vk = Split(value,":")
        up[vk[1]] = vk[2]
        --print("遍历 key:" .. vk[1] .. " value:" .. vk[2])
    end
    io.close(file)

    -- 解析
    for k,v in pairs(up) do

        if(k == user) then
        	print("user重复!注册失败!")
            return 0
        end
    end

    file = io.open("./up.data","a")
    io.output(file)
    io.write(user .. ":" .. pass .. "\n")
    io.close(file)
    
    runMcServer(user,pass)
    print("已经完成!注册成功!")
    
    return 1
end

--　第一次加载的时候注册一下ｍｃ服务器
file = io.open("./up.data","a+")
io.input(file)

for value in io.lines() do
    local vk = Split(value,":")
    runMcServer(vk[1],vk[2])  
end

io.close(file)

print("所有MC服务器数据加载完成!")
